package com.chencs.common.lm;


import com.alibaba.fastjson.JSON;
import com.chencs.common.BaseCtr;
import com.chencs.common.user.controller.LoginController;
import com.chencs.utils.CookiesUtil;
import com.chencs.vo.biz.lianmeng.LmUser;
import com.chencs.vo.common.user.UserModel;
import com.chencs.vo.net.request.RequestBase;
import com.chencs.vo.net.response.ResponseBase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@RequestMapping("/lmLogin")
@RestController
public class LmLoginCtr {
    private static final Logger logger = LoggerFactory.getLogger(LmLoginCtr.class);



    @RequestMapping(value = "/loginPage", method = RequestMethod.GET)
    public ModelAndView loginPage() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("lm/login");
        return modelAndView;
    }


    @RequestMapping(value = "/doLogin", method = RequestMethod.POST)
    public String doLogin(@RequestBody LmUser model,HttpSession session) {

        logger.info("/lmLogin/doLogin param: {}", JSON.toJSON(model) );
        session.setAttribute("user",model);
        ResponseBase requestBase = new ResponseBase();
        requestBase.setCode(0);
        requestBase.setMsg("登录成功");
        return JSON.toJSONString(requestBase);
    }
}
